home *** CD-ROM | disk | FTP | other *** search
- Path: admaix.sunydutchess.edu!ub!newserve!rebecca!rpi!not-for-mail
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++.moderated,comp.lang.c++
- Subject: Re: enum expression is IF statement
- Date: 16 Feb 1996 23:51:29 -0000
- Organization: Netcom
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: vandevod@cs.rpi.edu
- Message-ID: <4g35a1$5r9@netlab.cs.rpi.edu>
- References: <4fq7dc$pac@netlab.cs.rpi.edu> <4g1pj9$pqg@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Fri, 16 Feb 1996 23:06:26 GMT
-
- gstern@earth.usa.net (Greg Sternberg/PDS Inc) wrote:
-
- > Peter van Klaveren (P.v.Klaveren@bcs.cs.philips.com) wrote:
- > : enum
- > : {
- > : CSEQ_IDLE,
- > : CSEQ_ERROR,
- > : CSEQ_ABORT,
- > : CSEQ_WAIT4RESPONSE
- > : };
- >
- > : int state = 3;
- >
- > : if (state == CSEQ_WAIT4RESPONSE)
- > : {
- > : // this code is not executed!!!
- > : ...
- > : }
- >
- > You're making the assumption that the compiler is numbering your enums
- > sequentially from 0 - since the standard says nothing about how the
- > compiler could number your enums it could very well be using 0x1, 0x2,
- > 0x4, and 0x8.
-
- From draft 7.2:
-
- The identifiers in an enumerator-list are declared as
- constants, and can appear wherever constants are
- required. If no enumerator-definitions with = appear, then
- the values of the corresponding constants begin at zero and
- increase by one as the enumerator-list is read from left to
- right.
-
- The C standard (ISO 6.5.2.2) and ARM (7.2) also require this.
-
-
- Michael M Rubenstein
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-